package com.tudouji.project.mt.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.mt.domain.MtWhin;
import com.tudouji.project.mt.service.IMtWhinService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 美团入库单主Controller
 * 
 * @author tudouji
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/mt/whin")
public class MtWhinController extends BaseController
{
    @Autowired
    private IMtWhinService mtWhinService;

    /**
     * 查询美团入库单主列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtWhin mtWhin)
    {
        startPage();
        List<MtWhin> list = mtWhinService.selectMtWhinListPC(mtWhin);
        return getDataTable(list);
    }

    /**
     * 导出美团入库单主列表
     */
    @PreAuthorize("@ss.hasPermi('mt:whin:export')")
    @Log(title = "美团入库单主", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MtWhin mtWhin)
    {
        List<MtWhin> list = mtWhinService.selectMtWhinList(mtWhin);
        ExcelUtil<MtWhin> util = new ExcelUtil<MtWhin>(MtWhin.class);
        return util.exportExcel(list, "whin");
    }

    /**
     * 获取美团入库单主详细信息
     */
    @PreAuthorize("@ss.hasPermi('mt:whin:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mtWhinService.selectMtWhinById(id));
    }

    /**
     * 新增美团入库单主
     */
    @PreAuthorize("@ss.hasPermi('mt:whin:add')")
    @Log(title = "美团入库单主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MtWhin mtWhin)
    {
        return toAjax(mtWhinService.insertMtWhin(mtWhin));
    }

    /**
     * 修改美团入库单主
     */
    @PreAuthorize("@ss.hasPermi('mt:whin:edit')")
    @Log(title = "美团入库单主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MtWhin mtWhin)
    {
        return toAjax(mtWhinService.updateMtWhin(mtWhin));
    }

    /**
     * 删除美团入库单主
     */
    @PreAuthorize("@ss.hasPermi('mt:whin:remove')")
    @Log(title = "美团入库单主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mtWhinService.deleteMtWhinByIds(ids));
    }
}
